package cn.hexcloud.dga.common.scheduler;

import cn.hexcloud.dga.governance.service.MainAssessService;
import cn.hexcloud.dga.meta.service.TableMetaInfoService;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author jiangdan7
 */
@Component
public class MarketingTask {
    /**
     * @Scheduled(cron="0/10 * * * * *")
     * public void text1(){
     * System.out.println("text1测试"+System.currentTimeMillis());
     * }
     */
    @Autowired
    TableMetaInfoService tableMetaInfoService;

    @Autowired
    MainAssessService mainAssessService;

    @Value("${hive.schemaNames}")
    String schemas;

    @Scheduled(cron = "* 1 * * * *")
    public void checkProblem(){
        String assessDate = DateFormatUtils.format(new Date(),"yyyy-MM-dd");
        for (String schema : schemas.split(",")) {
            tableMetaInfoService.initTableMetaInfo(assessDate,schema);
        }
        mainAssessService.mainAssess(assessDate);
    }
}
